package org.chnxi.study.datastructrues.hash;

import java.util.Scanner;

public class HashTableDemo {

    public static void main(String[] args) {

        EmpHashTable empht = new EmpHashTable(7);

        String key = "";

        Scanner scanner = new Scanner(System.in);

        while(true){
            System.out.println("add:添加雇员");
            System.out.println("get:查找雇员");
            System.out.println("del:删除雇员");
            System.out.println("list:显示雇员");
            System.out.println("exit:退出");

            key = scanner.next();
            switch(key){
                case "add":
                    System.out.print("输入ID：");
                    int id = scanner.nextInt();
                    System.out.print("输入名字：");
                    String name = scanner.next();
                    Emp emp = new Emp();
                    emp.setId(id);
                    emp.setName(name);
                    empht.add(emp);
                    break;
                case "list":
                    empht.list();
                    break;
                case "get":
                    System.out.print("输入要查找的员工id：");
                    id = scanner.nextInt();
                    emp = empht.findEmpById(id);
                    System.out.println("找到的员工："+(emp==null?"null":emp));
                    break;
                case "del":
                    System.out.print("输入要删除的员工id:");
                    id = scanner.nextInt();
                    empht.delEmpById(id);
                    break;
                case "exit" :
                    return;
                default:
                    break;

            }
        }

    }

}
